package sel.me.websocket.learning.config;

import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionConnectedEvent;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
import org.springframework.web.socket.messaging.SessionSubscribeEvent;

import sel.me.websocket.learning.domain.AdminUserDO;

/**
 * Created by rajeevkumarsingh on 25/07/17.
 */
@Component
public class WebSocketEventListener {

    private static final Logger logger = LoggerFactory.getLogger(WebSocketEventListener.class);

    
    @EventListener
    public void handleWebSocketConnectListener(SessionConnectedEvent event) {
//    	AdminUserDO admin =  (AdminUserDO)SecurityUtils.getSubject().getSession().getAttribute("currentUser");
//        System.out.println(admin);
    }
    
    @EventListener
    public void handleSubscribeListener(SessionSubscribeEvent event) {
//    	AdminUserDO admin =  (AdminUserDO)SecurityUtils.getSubject().getSession().getAttribute("currentUser");
//        System.out.println(admin);
    }

    @EventListener
    public void handleWebSocketDisconnectListener(SessionDisconnectEvent event) {
//    	AdminUserDO admin =  (AdminUserDO)SecurityUtils.getSubject().getSession().getAttribute("currentUser");
//        System.out.println(admin);
    }
    

}
